<?php

namespace IMT\AccountBundle\Entity;

use IMT\AccountBundle\Models\AccountInterface;

use Doctrine\ORM\Mapping as ORM;

/**
 * IMT\AccountBundle\Models\Account
 *
 * @ORM\Table(name="account")
 * @ORM\Entity(repositoryClass="IMT\AccountBundle\Repository\AccountRepository")
 * @ORM\InheritanceType("JOINED")
 * @ORM\DiscriminatorColumn(name="typeAccount", type="string")
 * @ORM\DiscriminatorMap({
 * 		"imt" = "IMT\AccountBundle\Entity\AccountIMT",
 * 		"gmail" = "IMT\AccountBundle\Entity\AccountGmail"
 * })
 */
abstract class Account implements AccountInterface
{
	
	/**
	 * @ORM\Id
	 * @ORM\Column(type="integer")
	 * @ORM\generatedValue(strategy="AUTO")
	 */
	protected $id;
	
	/**
     * @var string $title
     *
     * @ORM\Column(name="title", type="string", length=255)
     */
    protected $title;
    
    /**
     * @var string $color
     *
     * @ORM\Column(name="color", type="string", length=255)
     */
    protected $color;

    /**
     * @var boolean $active
     *
     * @ORM\Column(name="active", type="boolean")
     */
    protected $active;
    	
    /**
     * @ORM\ManyToOne(targetEntity="IMT\UserBundle\Entity\User", inversedBy="accounts")
     * @ORM\joinColumn(name="user_id", referencedColumnName="id")
     */
    protected $user;
    
    /**
     * @ORM\ManyToMany(targetEntity="IMT\UserBundle\Entity\Contact", inversedBy="accounts", cascade={"all"})
     * @ORM\JoinTable(name="link_account_contact",
     *      joinColumns={@ORM\JoinColumn(name="account_id", referencedColumnName="id")},
     *      inverseJoinColumns={@ORM\JoinColumn(name="participant_id", referencedColumnName="id")}
     * )
     */
    protected $contacts;
    
    /**
     * @ORM\OneToMany(targetEntity="IMT\Plugins\ParticipantsBundle\Entity\ParticipantEvent", mappedBy="account", cascade={"all"})
     */
    protected $participantsEvent;
    
    /**
     * @ORM\ManyToMany(targetEntity="IMT\EventBundle\Entity\BaseEvent", mappedBy="accounts", cascade={"persist","update"})
     */
    protected $events;
    
    
	/**
	 * Constructor
	 */
	public function __construct()
	{
		$this->user = NULL;
		$this->contacts = new \Doctrine\Common\Collections\ArrayCollection();
		$this->participantsEvent = new \Doctrine\Common\Collections\ArrayCollection();
		$this->events = new \Doctrine\Common\Collections\ArrayCollection();
	}

    /**
     * Set title
     *
     * @param string $title
     */
    public function setTitle($title)
    {
        $this->title = $title;
    }

    /**
     * Get title
     *
     * @return string 
     */
    public function getTitle()
    {
        return $this->title;
    }

    /**
     * Set active
     *
     * @param boolean $active
     */
    public function setActive($active)
    {
        $this->active = $active;
    }

    /**
     * Get active
     *
     * @return boolean 
     */
    public function getActive()
    {
        return $this->active;
    }
    
    /**
     * Set color
     *
     * @param string $color
     */
    public function setColor($color)
    {
        $this->color = $color;
    }

    /**
     * Get color
     *
     * @return string 
     */
    public function getColor()
    {
        return $this->color;
    }

    /**
     * Set user
     *
     * @param IMT\UserBundle\Entity\User $user
     */
    public function setUser(\IMT\UserBundle\Entity\User $user)
    {
        $this->user = $user;
    }

    /**
     * Get user
     *
     * @return IMT\UserBundle\Entity\User 
     */
    public function getUser()
    {
        return $this->user;
    }

    /**
     * Add contacts
     *
     * @param IMT\UserBundle\Entity\Contact $contacts
     */
    public function addContact(\IMT\UserBundle\Entity\Contact $contact)
    {
        $this->contacts[] = $contact;
    }

    /**
     * Get contacts
     *
     * @return Doctrine\Common\Collections\Collection 
     */
    public function getContacts()
    {
        return $this->contacts;
    }
    
    /**
     * Set events
     *
     * @param IMT\EventBundle\Entity\BaseEvent $event
     */
    public function addEvent(\IMT\EventBundle\Entity\BaseEvent $event)
    {
    	$this->events[] = $event;
    }
    
    /**
     * Get events
     *
     * @return Doctrine\Common\Collections\Collection
     */
    public function getEvents()
    {
    	return $this->events;
    }
    
    /**
     * Add participantsEvent
     *
     * @param IMT\Plugins\ParticipantsBundle\Entity\ParticipantEvent $event
     */
    public function addParticipantEvent(\IMT\Plugins\ParticipantsBundle\Entity\ParticipantEvent $participant)
    {
    	$this->participantsEvent[] = $participant;
    }
    
    /**
     * Get participantsEvent
     *
     * @return IMT\EventBundle\Entity\ParticipantEvent
     */
    public function getParticipantsEvent()
    {
    	return $this->participantsEvent;
    }
    
    public function getClassName()
	{
		return basename(get_class($this));
	}

}